// socklist.cpp: implementation of the Csocklist class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "s.h"
#include "socklist.h"
#include "sockpoint.h"
#include "sock.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

Csocklist::Csocklist(CSDlg *pd)
{
	hand=new Csockpoint(pd);
	now=hand;
	end=hand;
}

Csocklist::~Csocklist()
{
	while(hand!=NULL)
	{
		now=hand->next;
		delete hand;
		hand=now;

	}
}

Csockpoint * Csocklist::addnew(CSDlg *pd)
{
	now=hand;
	while(1)
	{
		if(now->next==NULL)
		{
			now->next=new Csockpoint(pd);
			now=now->next;
			return now;
		}
		now=now->next;
	}
	/*
	end->next=new Csockpoint(pd);
	end=end->next;
	return end;
	*/
}

Csocklist::delone(Csock *ps)
{
	now=hand;
	while(now->next!=NULL)
	{
		if (now->next->psock==ps)
		{
			Csockpoint *temp;
			temp=now->next;
			now->next=now->next->next;
			temp->psock->Close();
			delete temp;	
			temp=NULL;
			break ;
		}
		now=now->next;
	}	
}

Csocklist::showall()
{
	now=hand->next;
	while(now!=NULL)
	{
		now->showall();
		now=now->next;
	}
}
